package com.cj.Mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cj.models.BookModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface BooksMapper extends BaseMapper<BookModel> {
   /* @Select("select  book_id , book_name , " +
            "book_price1  , book_kind ,b.kind_name " +
            "from books a inner join book_kinds b on a.book_kind=b.kind_id   ${ew.customSqlSegment}")
    public List<BookModel> selectBookByCid(Page<BookModel>page,@Param(Constants.WRAPPER) Wrapper wrapper);
*/

    @Select("<script>select  book_id , book_name , " +
            "book_price1  , book_kind ,b.kind_name " +
            "from books a ,book_kinds b where a.book_kind=b.kind_id   " +
            "<if test=\"ew.sqlSegment != null and ew.sqlSegment != '' and ew.nonEmptyOfWhere\" > " +
            "and ${ew.sqlSegment} </if> </script>")
    public List<BookModel> selectBookByCid(Page<BookModel> page, @Param(Constants.WRAPPER) Wrapper wrapper);


    @Select("SELECT b.book_id, b.book_name,b.book_price1,k.kind_name from books b,book_kinds k  ${ew.customSqlSegment}")
    public List<BookModel> selectBookByCid2(Page<BookModel>page,@Param(Constants.WRAPPER) Wrapper wrapper);


}
